package com.ls.lserp.modules.order.web;

import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.collections.map.HashedMap;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.freemarker.FreeMarkerTemplateUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.support.RequestContext;

import com.ls.lserp.common.config.Global;
import com.ls.lserp.common.persistence.AjaxDone;
import com.ls.lserp.common.persistence.Page;
import com.ls.lserp.common.utils.ResourcesUtil;
import com.ls.lserp.common.utils.StringUtils;
import com.ls.lserp.common.web.BaseController;
import com.ls.lserp.modules.common.entity.UploadFile;
import com.ls.lserp.modules.order.entity.BigcargoStyle;
import com.ls.lserp.modules.order.entity.BigcargoStyleFitProperty;
import com.ls.lserp.modules.order.entity.ProductionEntity;
import com.ls.lserp.modules.order.entity.SampleType;
import com.ls.lserp.modules.order.entity.UploadFileData;
import com.ls.lserp.modules.order.service.BigcargoStyleService;
import com.ls.lserp.modules.sys.entity.Brand;
import com.ls.lserp.modules.sys.entity.Dict;
import com.ls.lserp.modules.sys.entity.Sequence;
import com.ls.lserp.modules.sys.utils.DictUtils;
import com.ls.lserp.modules.sys.utils.SequenceUtil;
import com.ls.lserp.modules.sys.utils.SystemMessageUtils;
import com.ls.lserp.modules.sys.utils.UserUtils;

import freemarker.template.Configuration;
import groovy.util.ResourceException;

@Controller
@RequestMapping(value = "${adminPath}/bigcargo/style")
public class BigcargoStyleController extends BaseController {

	// 保存 编辑 删除 方法
	@Autowired
	private BigcargoStyleService bigcargoStyleService;
	@Autowired
	private Configuration freemarkerConfiguration;
	// 款式尺码Tab页区分
	private static final String STYLE_MASSAGE = "STYLE_MASSAGE";
	// 面料Tab页区分
	private static final String MATERIAL_TAB = "MATERIAL_TAB";
	// 意见要求Tab页区分
	private static final String FEED_BACK = "FEED_BACK";
	// 样板文件Tab页区分
	private static final String SAMPLE_FILE = "SAMPLE_FILE";
	// 资料文件Tab页区分
	private static final String MASSAGE_FILE = "MASSAGE_FILE";

	@ModelAttribute
	public BigcargoStyle get(@RequestParam(required = false) String id) {

		// 判断id是否为空
		if (StringUtils.isNotBlank(id)) {

			// 执行查询语句 查询基本信息
			return bigcargoStyleService.get(Long.parseLong(id));
		} else {

			// 若为空，实例化
			return new BigcargoStyle();
		}
	}

	/**
	 * @param model
	 * @return url
	 * @Title: 画面跳转用
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = { "" })
	public String list(Model model) {
		// 款式类别
		List<Dict> styleList2 = DictUtils.getDictList(ResourcesUtil.getConfig("style_category"));
		model.addAttribute("styleList", styleList2);
		// 款式来源
		List<Dict> styleSourceList = DictUtils.getDictList(ResourcesUtil.getConfig("style_source"));
		model.addAttribute("styleSourceList", styleSourceList);
		// 画面跳转
		return "modules/order/fashionStyle";
	}

	/**
	 * @param bigcargoStyle
	 * @param request
	 * @param response
	 * @return searchList
	 * @throws Exception
	 * @Title: 画面检索
	 * @Description: 查询页面
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = { "searchList" })
	@ResponseBody
	public String searchList(BigcargoStyle bigcargoStyle, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Map<Object, Object> listMap = new HashMap<Object, Object>();
		// ajax回调时使用的一览list名
		request.setAttribute(Global.LIST_NAME, "bigcargoStyle");
		// 画面取得的检索项目
		// 款号
		String styleNo = bigcargoStyle.getStyleNo();
		// 客户
		String ognizationName = bigcargoStyle.getOgnizationName();
		// 款式类别
		String styleCateGoryCd = bigcargoStyle.getStyleCateGoryCd();
		// 款式来源
		String styleSource = bigcargoStyle.getStyleSource();
		// 日期
		String dateFrom = bigcargoStyle.getDateFrom();
		// 日期
		String dateTo = bigcargoStyle.getDateTo();
		// 画面区分
		String otherImageFlg = bigcargoStyle.getOtherImageFlg();
		// 拼接字符串供分页使用
		StringBuilder searchParam = new StringBuilder();
		searchParam.append("&styleNo=");
		searchParam.append(styleNo);
		searchParam.append("&ognizationName=");
		searchParam.append(ognizationName);
		searchParam.append("&styleCateGoryCd=");
		searchParam.append(styleCateGoryCd);
		searchParam.append("&styleSource=");
		searchParam.append(styleSource);
		searchParam.append("&dateFrom=");
		searchParam.append(dateFrom);
		searchParam.append("&dateTo=");
		searchParam.append(dateTo);
		searchParam.append("&otherImageFlg=");
		searchParam.append(otherImageFlg);
		// 放到Attribute里，使用Global类里面的SEARCH_PAEAM作为key
		request.setAttribute(Global.SEARCH_PAEAM, searchParam.toString());
		// 查询一览页面数据
		Page<BigcargoStyle> page = bigcargoStyleService.findList(new Page<BigcargoStyle>(request, response), bigcargoStyle);
		// 读取系统路径
		// 读取文件生成字符串
		String strUri = request.getContextPath() + Global.getAdminPath();
		String strHtml = "";
		Map<String, Object> map = new HashedMap();
		map.put("adminUri", strUri);
		map.put("users", page.getList());
		map.put("pageNo", page.getPageNo());
		map.put("pageSize", page.getPageSize());
		if ("fashStyleSelRef".equals(bigcargoStyle.getOtherImageFlg())) {
			strHtml = FreeMarkerTemplateUtils
					.processTemplateIntoString(freemarkerConfiguration.getTemplate("fashStyleSelRef.ftl"), map);
		} else {
			strHtml = FreeMarkerTemplateUtils
					.processTemplateIntoString(freemarkerConfiguration.getTemplate("fashionStyle.ftl"), map);
		}
		listMap.put("bigcargoStyle", strHtml);
		listMap.put("page", page.getHtml());

		// ajax返回结果
		return renderString(response, listMap);
	}

	/**
	 * @param bigcargoStyle
	 * @param model
	 * @return url
	 * @throws ResourceException
	 * @Title: 新建画面迁移
	 * @Description: 新建画面迁移
	 */
	@RequiresPermissions("bigcargostyle:message:edit")
	@RequestMapping(value = { "createStyle" })
	public String createStyle(BigcargoStyle bigcargoStyle, Model model) {
		bigcargoStyle.setPhaseCd(ResourcesUtil.getConfig("audit_phase_style"));
		// 客户列表检索
		BigcargoStyle bigcargoStyleTemp = bigcargoStyleService.findCustomerList(bigcargoStyle);
		// 前台select组件使用（客户表）
		model.addAttribute("bigcargoStyleTemp", bigcargoStyleTemp);
		// 季节
		List<Dict> seasonList = DictUtils.getDictList(ResourcesUtil.getConfig("season"));
		model.addAttribute("seasonList", seasonList);
		// 款式类别
		List<Dict> styleList2 = DictUtils.getDictList(ResourcesUtil.getConfig("style_category"));
		model.addAttribute("styleList", styleList2);
		// 尺码组
		List<Dict> groupSizeList = DictUtils.getDictList(ResourcesUtil.getConfig("group_size"));
		model.addAttribute("groupSizeList", groupSizeList);
		// 创建人员
		model.addAttribute("user", UserUtils.getUser());
		// 物料部位
		List<Dict> materialPlacement = DictUtils.getDictList(ResourcesUtil.getConfig("material_placement"));
		List<UploadFile> myStyleFileList;
		// 获取图片关联ID
		String styleOptionId = bigcargoStyleService.getstyleOptionId(bigcargoStyle);
		// 获取所有图片信息
		myStyleFileList = bigcargoStyleService.getAllFile(styleOptionId);
		// 查看画面进去
		if (bigcargoStyle.getStyleID() > 0) {
			if ("".equals(bigcargoStyle.getUploadFile())) {
				bigcargoStyle.setUploadFile("/fragsmart-erp/a/static/images/pic-none.jpg");
			}
			List<Dict> sumGroupList = DictUtils.getDictList(bigcargoStyle.getStyleStyleGroupCd().split("-")[1]);
			// 品牌名集合
			List<Brand> brandNameCnList = bigcargoStyleService.selectBrandCnList(bigcargoStyle);
			BigcargoStyle objBigStyleList = bigcargoStyleService.styleSizeList(bigcargoStyle);
			model.addAttribute("StyleOptionList",
					objBigStyleList.getBigcargoStyleFitProperty().getBigcargoStyleFitProperty());
			model.addAttribute("styleFit", objBigStyleList.getSampleTypeDataList().getStyleFit().getStyleFitList());
			model.addAttribute("styleSizeList", objBigStyleList.getSampleTypeDataList().getSampleTypeList());
			model.addAttribute("cgMaterialList", objBigStyleList.getChangeMaterial().getCgMatList());
			model.addAttribute("feedBackList", objBigStyleList.getStyleFeedBack().getStyleFeedBackList());
			model.addAttribute("imageList", objBigStyleList.getUploadFileData().getAllDataList());
			model.addAttribute("afterItem", objBigStyleList);
			model.addAttribute("brandNameCnList", brandNameCnList);
			model.addAttribute("bigcargoStyleTempID", bigcargoStyle);
			model.addAttribute("sumGroupList", sumGroupList);
			model.addAttribute("productionList", objBigStyleList.getProductionEntity().getProductionList());

			model.addAttribute("difKbn", "1");
			// 新建按钮进去
		} else {
			model.addAttribute("difKbn", "2");
		}
		model.addAttribute("myStyleFileList", myStyleFileList);
		model.addAttribute("materialPlacement", materialPlacement);
		model.addAttribute("user", UserUtils.getUser().getFirstName() + UserUtils.getUser().getLastName());
		return "modules/order/fashionStyleCreate";
	}

	/**
	 * @param bigcargoStyle
	 * @param model
	 * @return url
	 * @throws ResourceException
	 * @Title: 尺码组对应联动
	 * @Description: 尺码组对应联动
	 */
	@RequiresPermissions("bigcargostyle:message:edit")
	@RequestMapping(value = { "styleGroupList" })
	public String styleGroupList(BigcargoStyle bigcargoStyle, Model model) {
		// 客户列表检索
		BigcargoStyle bigcargoStyleTemp = bigcargoStyleService.findCustomerList(bigcargoStyle);
		// 前台select组件使用（客户表）
		model.addAttribute("bigcargoStyleTemp", bigcargoStyleTemp);
		// 季节
		List<Dict> seasonList = DictUtils.getDictList(ResourcesUtil.getConfig("season"));
		model.addAttribute("seasonList", seasonList);
		// 款式类别
		List<Dict> styleList2 = DictUtils.getDictList(ResourcesUtil.getConfig("style_category"));
		model.addAttribute("styleList", styleList2);
		// 尺码组
		List<Dict> groupSizeList = DictUtils.getDictList(ResourcesUtil.getConfig("group_size"));

		model.addAttribute("groupSizeList", groupSizeList);

		return "modules/order/fashionStyleCreate";
	}

	/**
	 * 联动返回款式
	 *
	 * @param code
	 * @param response
	 * @return
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = "styleSize")
	@ResponseBody
	public String styleSize(String code, HttpServletResponse response) {

		List<Dict> styleSizeList = DictUtils.getDictList(code);

		return renderString(response, styleSizeList);
	}

	/**
	 * @param bigcargoStyle
	 * @param model
	 * @return url
	 * @Title: 尺码组对应联动
	 * @Description: 尺码组对应联动
	 */
	@RequiresPermissions("bigcargostyle:message:edit")
	@RequestMapping(value = { "addSpecSize" })
	public String addSpecSize(BigcargoStyle bigcargoStyle, Model model) {
		// 客户列表检索
		BigcargoStyle bigcargoStyleTemp = bigcargoStyleService.findCustomerList(bigcargoStyle);
		// 前台select组件使用（客户表）
		model.addAttribute("bigcargoStyleTemp", bigcargoStyleTemp);
		// 季节
		List<Dict> seasonList = DictUtils.getDictList(ResourcesUtil.getConfig("season"));
		model.addAttribute("seasonList", seasonList);
		// 款式类别
		List<Dict> styleList2 = DictUtils.getDictList(ResourcesUtil.getConfig("style_category"));
		model.addAttribute("styleList", styleList2);
		// 尺码组
		List<Dict> groupSizeList = DictUtils.getDictList(ResourcesUtil.getConfig("group_size"));
		model.addAttribute("groupSizeList", groupSizeList);

		return "modules/order/addSize";
	}

	/**
	 * @param model
	 * @return url
	 * @Title: 意见要求画面迁移
	 * @Description: 画面迁移
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = { "addStyleComments" })
	public String addStyleComments(BigcargoStyle bigcargoStyle, Model model) {
		// 物料类别
		List<Dict> opinionList = DictUtils.getDictList(ResourcesUtil.getConfig("opinion"));
		model.addAttribute("opinionList", opinionList);
		// 创建人员
		model.addAttribute("user", UserUtils.getUser());
		// 创建时间
		Date tempDate = new Date();
		SimpleDateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd hh:ss");
		model.addAttribute("createDateTime", dateFormater.format(tempDate));
		model.addAttribute("bigcargoStyle", bigcargoStyle);
		return "modules/order/addStyleComments";
	}

	/**
	 * @param bigcargoStyle
	 * @param model
	 * @return url
	 * @Title: 面辅配料画面迁移
	 * @Description: 下拉列表生成
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = { "changeMaterialList" })
	public String changeMaterial(BigcargoStyle bigcargoStyle, Model model) {
		// 物料类别
		List<Dict> materialList = DictUtils.getDictList(ResourcesUtil.getConfig("categoryCD"));
		model.addAttribute("materialList", materialList);
		// 款式类别
		List<Dict> styleList = DictUtils.getDictList(ResourcesUtil.getConfig("style_category"));
		model.addAttribute("styleList", styleList);
		// 物料部位
		List<Dict> materialPlacement = DictUtils.getDictList(ResourcesUtil.getConfig("material_placement"));
		model.addAttribute("materialPlacement", materialPlacement);
		model.addAttribute("bigcargoStyle", bigcargoStyle);
		return "modules/order/changeMaterial";
	}

	/**
	 * @param bigcargoStyle
	 * @param model
	 * @return url
	 * @Title: 样板文件画面迁移
	 * @Description: 下拉列表生成
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = { "uploadFileMaterial" })
	public String uploadFileMaterial(BigcargoStyle bigcargoStyle, Model model) {
		// 物料类别
		List<Dict> materialList = DictUtils.getDictList(ResourcesUtil.getConfig("categoryCD"));
		model.addAttribute("materialList", materialList);
		String flg = bigcargoStyle.getUploadFlg();
		if ("4".equals(flg)) {
			model.addAttribute("pageFlg", flg);
		} else if ("5".equals(flg)) {
			model.addAttribute("pageFlg", flg);
		} else if ("1".equals(flg)) {
			model.addAttribute("pageFlg", flg);
		}
		// 创建人员
		model.addAttribute("user", UserUtils.getUser());
		return "modules/order/uploadFileMaterial";
	}

	/**
	 * @param bigcargoStyle
	 * @param response
	 * @param session
	 * @return url
	 * @Title: 面辅配料画面
	 * @Description: 检索
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = "searchForm")
	@ResponseBody
	public String searchForm(BigcargoStyle bigcargoStyle, HttpServletResponse response, HttpSession session)
			throws Exception {
		Map<Object, Object> listMap = new HashMap<Object, Object>();
		// 款式集合
		List<BigcargoStyle> styleOptionList = bigcargoStyleService.getNextChildPage(bigcargoStyle);
		String strHtml = "";
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("StyleOptionList", styleOptionList);
		// 阶段Code
		map.put("stageCode", ResourcesUtil.getConfig("audit_phase_cd"));
		strHtml = FreeMarkerTemplateUtils
				.processTemplateIntoString(freemarkerConfiguration.getTemplate("changeMaterial.ftl"), map);
		session.setAttribute("tempHtml", strHtml);
		listMap.put("StyleOptionList", strHtml);
		// ajax返回结果
		return renderString(response, listMap);
	}

	/**
	 * @param bigcargoStyle
	 * @param request
	 * @param response
	 * @return url
	 * @Title: 动态生成规则尺寸layout
	 * @Description: 检索
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = "doStyleSizeLayout")
	@ResponseBody
	public String doStyleSizeLayout(BigcargoStyle bigcargoStyle, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Map<Object, Object> listMap = new HashMap<Object, Object>();
		String strCd[] = bigcargoStyle.getPopupCategoryCd().split("-");
		String productionCategoryCd = strCd[0] + "-" + strCd[1];
		ProductionEntity productionEntity = new ProductionEntity();
		productionEntity.setStyleCategoryCd(productionCategoryCd);
		bigcargoStyle.setPopupCategoryCd(strCd[1] + "_FIT_ITEM");
		// 款式集合
		List<BigcargoStyleFitProperty> styleOptionList = bigcargoStyleService.findBigcargoStyleFitProperty(bigcargoStyle);
		List<ProductionEntity> proList = bigcargoStyleService.selProductinoList(productionEntity);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("StyleOptionList", styleOptionList);
		map.put("springMacroRequestContext", new RequestContext(request));
		String strHtml = "";
		strHtml = FreeMarkerTemplateUtils
				.processTemplateIntoString(freemarkerConfiguration.getTemplate("sizeFitProperty.ftl"), map);
		map = new HashMap<String, Object>();
		map.put("productionList", proList);
		String strProductionHtml = "";
		strProductionHtml = FreeMarkerTemplateUtils
				.processTemplateIntoString(freemarkerConfiguration.getTemplate("productionTableList.ftl"), map);
		listMap.put("strProductionHtml", strProductionHtml);
		listMap.put("sizeFitPropertyList", strHtml);
		// ajax返回结果
		return renderString(response, listMap);
	}

	/**
	 * @param model
	 * @return url
	 * @Title: 动态生成规则尺寸layout
	 * @Description: 检索
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = "createSample")
	public String createSample(Model model) {
		// 样品类别
		List<Dict> sampleType = DictUtils.getDictList(ResourcesUtil.getConfig("sample_type"));
		model.addAttribute("sampleType", sampleType);
		// ajax返回结果
		return "modules/order/sampleCreate";
	}

	/**
	 * @param bigcargoStyle
	 * @param response
	 * @return url
	 * @Title: 新建编辑保存
	 * @Description: 检索
	 */
	@RequiresPermissions("bigcargostyle:message:edit")
	@RequestMapping(value = "saveData")
	@ResponseBody
	public String saveData(BigcargoStyle bigcargoStyle, HttpServletResponse response) throws ResourceException {
		// 客户简称
		String cusTemp = bigcargoStyle.getOgnizaitonSimpleName();
		// 款式年份
		String styYearTemp = bigcargoStyle.getStyleYear();
		// 款式季节ID
		String stySeasonTemp = bigcargoStyle.getMaterialSeasonCd();
		// 款式类别ID
		String styCargoTemp = bigcargoStyle.getStyleCategoryId();
		// 款式编号后三位取得
		Sequence sequence = SequenceUtil.styleNo(bigcargoStyle.getMaterialSeason(), bigcargoStyle.getStyleCateGoryCd());
		String sequenceNoTemp = sequence.getReturnCode();
		String styleNo = cusTemp + styYearTemp + stySeasonTemp + "0" + styCargoTemp + sequenceNoTemp;
		// 款式编号设置
		bigcargoStyle.setStyleNumber(styleNo);
		bigcargoStyle.setSampleRequestNo("10" + styleNo);

		bigcargoStyle.setPhaseCd(ResourcesUtil.getConfig("audit_phase_cd"));
		try {
			if ("1".equals(bigcargoStyle.getUpOrCreateflg())) {
				bigcargoStyleService.insertStyleContract(bigcargoStyle);
			} else {
				bigcargoStyleService.updateStyle(bigcargoStyle);
			}

		} catch (SQLException e) {
			// 返回提示信息
			return renderString(response, AjaxDone.error(getText("warehouse_edit_save_msg_fail")));
		}
		// ajax返回结果
		// 保存成功返回提示信息
		return renderString(response, AjaxDone.ok(SystemMessageUtils.getMessageName("warehouse_edit_save_msg_success")));
	}

	/**
	 * @param bigcargoStyle
	 * @param request
	 * @param response
	 * @return list
	 * @Title: 参考款式检索
	 * @Description: 检索
	 */
	@RequiresPermissions("bigcargostyle:message:edit")
	@RequestMapping(value = "selectStyle")
	@ResponseBody
	public String selectStyle(BigcargoStyle bigcargoStyle, HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		Map<Object, Object> listMap = new HashMap<Object, Object>();
		Map<String, Object> map;
		BigcargoStyle bigStyleObj;
		BigcargoStyle imageAllFileData = bigcargoStyleService.selectAllUploudFile(bigcargoStyle);
		// 款式图片list生成
		List<UploadFileData> imageListTemp = imageAllFileData.getUploadFileData().getAllDataList();
		String allFlie = bigcargoStyle.getStyleFile();
		String urlTemp = "";
		String imageHtml = "";
		String fitSizeHtml = "";
		String changeMaterialHtml = "";
		String feedBackHtml = "";
		String uploadFileHtml = "";
		String uploadFileDataHtml = "";
		// 各Tab页分别检索
		if (STYLE_MASSAGE.equals(bigcargoStyle.getTabFlg())) {
			bigStyleObj = bigcargoStyleService.styleMassageTab(bigcargoStyle);
			// 款式尺码list生成
			List<SampleType> styleSizeList = bigStyleObj.getSampleTypeDataList().getSampleTypeList();
			// 生成hidden用url字符串
			for (int i = 0; i < imageListTemp.size(); i++) {
				if (imageListTemp.get(i).getFileKbn() == 0) {
					urlTemp += "|" + (imageListTemp.get(i).getFilePath() + imageListTemp.get(i).getUploadFileName());
				}
			}
			listMap.put("urlTemp", urlTemp);
			map = new HashMap<String, Object>();
			map.put("imageList", imageListTemp);
			map.put("allFlie", allFlie);
			map.put("user", UserUtils.getUser().getFirstName() + UserUtils.getUser().getLastName());
			// 生成款式图片的HTML
			imageHtml = createHtml(map, "imageUrlList.ftl");
			map = new HashMap<String, Object>();
			map.put("styleSizeList", styleSizeList);
			// 生成款式图片的HTML
			String styleSizeHtml = createHtml(map, "styleOptionList.ftl");
			// 规格尺寸数据取得
			map = new HashMap<String, Object>();
			map.put("StyleOptionList", bigStyleObj.getBigcargoStyleFitProperty().getBigcargoStyleFitProperty());
			map.put("styleSizeList", styleSizeList);
			map.put("styleFit", bigStyleObj.getSampleTypeDataList().getStyleFit().getStyleFitList());
			map.put("springMacroRequestContext", new RequestContext(request));
			map.put("otherImageFlg", "");
			// 生成规格尺寸画面HTML
			fitSizeHtml = createHtml(map, "selectSizeFitProperty.ftl");
			// 生成规格尺寸模板
			map = new HashMap<String, Object>();
			map.put("StyleOptionList", bigStyleObj.getBigcargoStyleFitProperty().getBigcargoStyleFitProperty());
			map.put("springMacroRequestContext", new RequestContext(request));
			String sizeModelHtml = "";
			sizeModelHtml = createHtml(map, "sizeFitProperty.ftl");
			// ajax前后台交互用list
			listMap.put("sizeModeHtml", sizeModelHtml);
			listMap.put("fitSizeHtml", fitSizeHtml);
			listMap.put("styleSizeHtml", styleSizeHtml);
			listMap.put("imageListHtml", imageHtml);
		} else if (MATERIAL_TAB.equals(bigcargoStyle.getTabFlg())) {
			bigStyleObj = bigcargoStyleService.materialTab(bigcargoStyle);
			// 面辅料数据取得
			map = new HashMap<String, Object>();
			map.put("cgMaterialList", bigStyleObj.getChangeMaterial().getCgMatList());
			List<Dict> materialPlacement = DictUtils.getDictList(ResourcesUtil.getConfig("material_placement"));
			map.put("itemList", materialPlacement);
			map.put("springMacroRequestContext", new RequestContext(request));
			// 生成面辅料画面的HTML
			changeMaterialHtml = createHtml(map, "changeStyleMaterial.ftl");
			listMap.put("changeMaterialHtml", changeMaterialHtml);
		} else if (FEED_BACK.equals(bigcargoStyle.getTabFlg())) {
			bigStyleObj = bigcargoStyleService.feedBackTab(bigcargoStyle);
			// 意见要求数据取得
			map = new HashMap<String, Object>();
			map.put("feedBackList", bigStyleObj.getStyleFeedBack().getStyleFeedBackList());
			map.put("user", UserUtils.getUser().getFirstName() + UserUtils.getUser().getLastName());
			// 意见要求画面的HTML
			feedBackHtml = createHtml(map, "opinionList.ftl");
			listMap.put("feedBackHtml", feedBackHtml);
		} else if (SAMPLE_FILE.equals(bigcargoStyle.getTabFlg())) {
			// 样板文件
			map = new HashMap<String, Object>();
			map.put("imageList", imageListTemp);
			map.put("otherImageFlg", "");
			map.put("user", UserUtils.getUser().getFirstName() + UserUtils.getUser().getLastName());
			// 生成样板文件画面的HTML
			uploadFileHtml = createHtml(map, "upLoadFileList.ftl");
			listMap.put("uploadFileHtml", uploadFileHtml);
		} else if (MASSAGE_FILE.equals(bigcargoStyle.getTabFlg())) {
			// 资料文件
			map = new HashMap<String, Object>();
			map.put("imageList", imageListTemp);
			map.put("otherImageFlg", "");
			map.put("user", UserUtils.getUser().getFirstName() + UserUtils.getUser().getLastName());
			// 生成资料文件画面的HTML
			uploadFileDataHtml = createHtml(map, "upLoadFileListData.ftl");
			listMap.put("uploadFileDataHtml", uploadFileDataHtml);
		}
		return renderString(response, listMap);
	}

	/**
	 * @param bigcargoStyle
	 * @param response
	 * @return 品牌中文list
	 * @Title: 供货商与品牌连动
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = "selectBrandCn")
	@ResponseBody
	public String selectBrandCnList(BigcargoStyle bigcargoStyle, HttpServletResponse response) {
		Map<Object, Object> listMap = new HashMap<Object, Object>();
		// 品牌名集合
		List<Brand> brandNameCnList = bigcargoStyleService.selectBrandCnList(bigcargoStyle);
		listMap.put("brandNameCnList", brandNameCnList);
		// ajax返回结果
		return renderString(response, listMap);
	}

	/**
	 * @param bigcargoStyle
	 * @param response
	 * @return 品牌中文list
	 * @Title: 供货商与品牌连动
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = "findBrandCnList")
	@ResponseBody
	public String findBrandCnList(BigcargoStyle bigcargoStyle, HttpServletResponse response) {
		Map<Object, Object> listMap = new HashMap<Object, Object>();
		// 品牌名集合
		List<Brand> brandNameCnList = bigcargoStyleService.selectBrandCnList(bigcargoStyle);
		listMap.put("brandNameCnList", brandNameCnList);
		// ajax返回结果
		return renderString(response, listMap);
	}

	/**
	 * @return HTML
	 * @Title: 生成HTML
	 */
	public String createHtml(Map<String, Object> map, String fileName) {
		String tempHtml = "";
		try {
			tempHtml = FreeMarkerTemplateUtils.processTemplateIntoString(freemarkerConfiguration.getTemplate(fileName), map);
		} catch (Exception e) {
			return tempHtml;
		}
		return tempHtml;
	}

	/**
	 * @param model
	 * @return url
	 * @Title: 画面跳转用
	 */
	@RequiresPermissions("bigcargostyle:message:view")
	@RequestMapping(value = { "refStyleSel" })
	public String refStyleSel(Model model) {
		// 款式类别
		List<Dict> styleList2 = DictUtils.getDictList(ResourcesUtil.getConfig("style_category"));
		model.addAttribute("styleList", styleList2);
		// 画面跳转
		return "modules/order/fashStyleSelRef";
	}
}
